<div id="content">
    <div smart-include="sensor/views/sub-header.tpl.html"></div>
    <div class="clearfix margin-bottom-10">
        <div class="pull-left margin-right-20">
            <a class="btn btn-labeled btn-primary" data-toggle="modal" data-target="#addAlert"> <span class="btn-label">
                <i class="glyphicon glyphicon-plus"></i></span>添加协议
            </a>
        </div>
    </div>
    <div class="table-responsive">
        <table class="table table-bordered table-hover no-margin font-sml table-striped sensor_table">
            <thead>
            <tr>
                <th style="width: 10%">操作</th>
                <th class="text-align-center">名称</th>
                <th class="text-align-center">端口</th>
                <th class="text-align-center">描述</th>
                <th class="text-align-center">数据</th>
            </tr>
            </thead>
            <tbody>
            <tr ng-repeat="data in datas">
                <td>
                    <button class='btn btn-xs btn-default' uib-tooltip='查看' tooltip-append-to-body='true'data-toggle="modal" ng-click="editProtocol(data.port)"><i class='fa fa-eye'></i></button>
                    <button class='btn btn-xs btn-default' uib-tooltip='编辑' tooltip-append-to-body='true' data-toggle="modal" data-target="#editAlert" ng-click="showEditAlert(data)"><i class='fa fa-pencil'></i></button>
                    <button class='btn btn-xs btn-default' uib-tooltip='删除' tooltip-append-to-body='true'data-toggle="modal" data-target="#delAlert" ng-click="showDelDialog(data.id,data.port)"><i class='fa fa-times'></i></button>
                </td>
                <td class="text-align-center">{{data.name}}</td>
                <td class="text-align-center">{{data.port}}</td>
                <td class="text-align-center">{{data.des}}</td>
                <td class="text-align-center">
                    <a ui-sref="app.sensor.historicaldata({port:data.port})">
                        查看
                    </a>
                </td>
            </tr>
            </tbody>
        </table>
    </div>
    <!-- end widget content -->
    <div class="dt-toolbar-footer">
        <tm-pagination conf="paginationConf"></tm-pagination>
    </div>

    <div class="modal fade" id="addAlert" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                        &times;
                    </button>
                    <h4 class="modal-title">添加协议</h4>
                </div>
                <div class="modal-body">
                    <form  class="form-horizontal">
                        <div class="form-group">
                            <!-- <label class="col-sm-2 control-label">端口</label>
                            <div class="col-sm-3">
                              <input type="text"  ng-model="addobj.port" class="form-control" placeholder="端口">
                            </div> -->
                            <label class="col-sm-2 control-label">名称</label>
                            <div class="col-sm-4">
                                <input type="text"  ng-model="addobj.name" class="form-control" placeholder="名称">
                                <span style="color: red; position: absolute; top: 0; right: 0">*</span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">内容长度</label>
                            <div class="col-sm-3">
                                <input type="text"  ng-model="contentlen.offset" class="form-control" placeholder="偏移量">
                                <span style="color: red; position: absolute; top: 0; right: 0">*</span>
                            </div>
                            <div class="col-sm-2">
                                <input type="text"  ng-model="contentlen.len" class="form-control" placeholder="长度">
                                <span style="color: red; position: absolute; top: 0; right: 0">*</span>
                            </div>
                            <div class="col-sm-4">
                                <select class="form-control" ng-model="contentlen.includeht">
                                    <option  value="0">不包含头部</option>
                                    <option  value="1">包含头部</option>
                                </select>
                                <span style="color: red; position: absolute; top: 0; right: 0">*</span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">命令</label>
                            <div class="col-sm-4">
                                <input type="text"  ng-model="cmd.offset" class="form-control" placeholder="偏移量">
                                <span style="color: red; position: absolute; top: 0; right: 0">*</span>
                            </div>
                            <div class="col-sm-5">
                                <input type="text"  ng-model="cmd.len" class="form-control" placeholder="长度">
                                <span style="color: red; position: absolute; top: 0; right: 0">*</span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">设备编号</label>
                            <div class="col-sm-4">
                                <input type="text"  ng-model="deviceid.offset" class="form-control" placeholder="偏移量">
                                <span style="color: red; position: absolute; top: 0; right: 0">*</span>
                            </div>
                            <div class="col-sm-5">
                                <input type="text"  ng-model="deviceid.len" class="form-control" placeholder="长度">
                                <span style="color: red; position: absolute; top: 0; right: 0">*</span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">其他</label>
                            <div class="col-sm-4">
                                <input type="text"  ng-model="other.offset" class="form-control" placeholder="偏移量">
                                <span style="color: red; position: absolute; top: 0; right: 0">*</span>
                            </div>
                            <div class="col-sm-5">
                                <input type="text"  ng-model="other.len" class="form-control" placeholder="长度">
                                <span style="color: red; position: absolute; top: 0; right: 0">*</span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">描述</label>
                            <div class="col-sm-9">
                              <textarea class="form-control" ng-model="addobj.des" placeholder="描述" rows='2'>

                              </textarea>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button class="btn btn-default"data-dismiss="modal">关闭</button>
                    <button class="btn btn-primary" ng-click="sure_add()">提交</button>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->
    <div class="modal fade in" id="editAlert" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                        &times;
                    </button>
                    <h4 class="modal-title" id="myModalLabel">编辑</h4>
                </div>
                <div class="modal-body">
                    <form  class="form-horizontal">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">端口</label>
                            <div class="col-sm-3">
                                <input type="text"  ng-model="editobj.port" class="form-control" placeholder="端口">
                                <span style="color: red; position: absolute; top: 0; right: 0">*</span>
                            </div>
                            <label class="col-sm-2 control-label">名称</label>
                            <div class="col-sm-4">
                                <input type="text"  ng-model="editobj.name" class="form-control" placeholder="名称">
                                <span style="color: red; position: absolute; top: 0; right: 0">*</span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">内容长度</label>
                            <div class="col-sm-3">
                                <input type="text"  ng-model="contentlen_edit.offset" class="form-control" placeholder="偏移量">
                                <span style="color: red; position: absolute; top: 0; right: 0">*</span>
                            </div>
                            <div class="col-sm-2">
                                <input type="text"  ng-model="contentlen_edit.len" class="form-control" placeholder="长度">
                                <span style="color: red; position: absolute; top: 0; right: 0">*</span>
                            </div>
                            <div class="col-sm-4">
                                <select class="form-control" ng-model="contentlen_edit.includeht">
                                    <option  value="0">不包含头部</option>
                                    <option  value="1">包含头部</option>
                                </select>
                                <span style="color: red; position: absolute; top: 0; right: 0">*</span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">命令</label>
                            <div class="col-sm-4">
                                <input type="text"  ng-model="cmd_edit.offset" class="form-control" placeholder="偏移量">
                                <span style="color: red; position: absolute; top: 0; right: 0">*</span>
                            </div>
                            <div class="col-sm-5">
                                <input type="text"  ng-model="cmd_edit.len" class="form-control" placeholder="长度">
                                <span style="color: red; position: absolute; top: 0; right: 0">*</span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">设备编号</label>
                            <div class="col-sm-4">
                                <input type="text"  ng-model="deviceid_edit.offset" class="form-control" placeholder="偏移量">
                                <span style="color: red; position: absolute; top: 0; right: 0">*</span>
                            </div>
                            <div class="col-sm-5">
                                <input type="text"  ng-model="deviceid_edit.len" class="form-control" placeholder="长度">
                                <span style="color: red; position: absolute; top: 0; right: 0">*</span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">其他</label>
                            <div class="col-sm-4">
                                <input type="text"  ng-model="other_edit.offset" class="form-control" placeholder="偏移量">
                                <span style="color: red; position: absolute; top: 0; right: 0">*</span>
                            </div>
                            <div class="col-sm-5">
                                <input type="text"  ng-model="other_edit.len" class="form-control" placeholder="长度">
                                <span style="color: red; position: absolute; top: 0; right: 0">*</span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">描述</label>
                            <div class="col-sm-9">
                              <textarea class="form-control" ng-model="editobj.des" placeholder="描述" rows='2'></textarea>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button class="btn btn-default"data-dismiss="modal">关闭</button>
                    <button class="btn btn-primary" ng-click="sure_edit()">提交</button>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->
    <div class="modal fade in" id="delAlert" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                        ×
                    </button>
                    <h4 class="modal-title">信息</h4>
                </div>
                <div class="modal-body">
                    <p>
                        您确实要删除这条协议吗？
                    </p>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">
                        关闭
                    </button>
                    <button type="button" class="btn btn-primary" ng-click="sure_del()">
                        确认
                    </button>
                </div>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
    <!-- /.modal-dialog -->
</div>
<!-- END MAIN CONTENT